package logic;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;

public abstract class GameObject {
	protected Vec2D pos = new Vec2D(0, 0);
	protected Vec2D dir = new Vec2D(0, 0);
	protected float recMass = 10.0f;
	protected Color color = Color.yellow;
	protected float friction = 0.98f;
	
	public float getFriction() {
		return friction;
	}

	public void setFriction(float friction) {
		this.friction = friction;
	}

	public void setPosition(float x, float y)
	{
		pos.x = x;
		pos.y = y;
	}
	
	public void setPosition(Vec2D pos)
	{
		this.pos.x = pos.x;
		this.pos.y = pos.y;
	}
	
	public Vec2D getPosition()
	{
		return pos;
	}
	
	public abstract void draw(Graphics2D g);
	
	public void applyForce(float fx, float fy)
	{
		dir.x += fx * recMass;
		dir.y += fy * recMass;
	}
	
	public void applyForce(Vec2D f)
	{
		applyForce(f.x, f.y);
	}
	
	public abstract void checkBounds(float x1, float y1, float x2, float y2, float bounce);
	public abstract Vec2D collisionWith(GameObject obj);
	public abstract void backtrack(Vec2D col);
	
	public void setMass(float mass)
	{
		if(mass != 0.0f)
			recMass = 1.0f / mass;
	}
	
	public void setStatic()
	{
		recMass = 0.0f;
	}
	
	public float getMass() { return 1.0f / recMass; }
	
	public void setColor(Color color)
	{
		this.color = color;
	}
	
	public Color getColor()
	{
		return color;
	}
	
	public void update() { }
}
